package text_2023_09_22;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Vv
 * @version 1.0
 * @project coding_learn
 * @description
 * @date 2023/9/22 09:46:50
 */
public class isRightFormat {
    public static boolean isRight1(String s){
        int startIndex = s.indexOf('/');
        int endIndex = s.lastIndexOf('/');
        if(startIndex == -1 || startIndex == endIndex){
            return false;
        }
        return true;
    }
    public static boolean isRight(String s){
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        boolean is = true;
        try {
            Date date = format.parse(s);
        } catch (ParseException e) {
            is = false;
           // throw new RuntimeException(e);
        }
        return false;
    }

    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd    HH:mm:ss");
        String nowStr = sdf.format(new Date());
        System.out.println(nowStr);
        try{
            Date d = sdf.parse("2011-11-11    11:11:11");
            System.out.println(d);
        }catch (Exception e){
            System.out.println("错");
            e.printStackTrace();
        }
    }

}
